if exists (select 1
            from  sysindexes
           where  id    = object_id('bd_repair_attendance')
            and   name  = 'order_index_repair_attendance'
            and   indid > 0
            and   indid < 255)
   drop index bd_repair_attendance.order_index_repair_attendance
go

if exists (select 1
            from  sysobjects
           where  id = object_id('bd_repair_attendance')
            and   type = 'U')
   drop table bd_repair_attendance
go

/*==============================================================*/
/* Table: bd_repair_attendance                                  */
/*==============================================================*/
create table bd_repair_attendance (
   order_id             numeric              not null,
   order_no             varchar(10)          not null,
   start_date           date                 not null,
   end_date             date                 not null,
   people_num           int                  not null,
   remark               varchar(2000)        null,
   creater_id           varchar(255)         not null,
   create_time          datetime             not null default getdate(),
   is_del               int                  not null default 0,
   pc_ip                varchar(20)          null,
   pc_name              varchar(100)         null,
   constraint PK_BD_REPAIR_ATTENDANCE primary key (order_id)
)
go

if exists (select 1 from  sys.extended_properties
           where major_id = object_id('bd_repair_attendance') and minor_id = 0)
begin 
   declare @CurrentUser sysname 
select @CurrentUser = user_name() 
execute sp_dropextendedproperty 'MS_Description',  
   'user', @CurrentUser, 'table', 'bd_repair_attendance' 
 
end 


select @CurrentUser = user_name() 
execute sp_addextendedproperty 'MS_Description',  
   '补出勤',
   'user', @CurrentUser, 'table', 'bd_repair_attendance'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_repair_attendance')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'order_id')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_repair_attendance', 'column', 'order_id'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '表ID',
   'user', @CurrentUser, 'table', 'bd_repair_attendance', 'column', 'order_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_repair_attendance')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'order_no')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_repair_attendance', 'column', 'order_no'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '补出勤单ID',
   'user', @CurrentUser, 'table', 'bd_repair_attendance', 'column', 'order_no'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_repair_attendance')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'start_date')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_repair_attendance', 'column', 'start_date'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '开始日期',
   'user', @CurrentUser, 'table', 'bd_repair_attendance', 'column', 'start_date'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_repair_attendance')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'end_date')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_repair_attendance', 'column', 'end_date'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '结束日期',
   'user', @CurrentUser, 'table', 'bd_repair_attendance', 'column', 'end_date'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_repair_attendance')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'people_num')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_repair_attendance', 'column', 'people_num'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '总人数',
   'user', @CurrentUser, 'table', 'bd_repair_attendance', 'column', 'people_num'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_repair_attendance')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'remark')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_repair_attendance', 'column', 'remark'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '补出勤原因',
   'user', @CurrentUser, 'table', 'bd_repair_attendance', 'column', 'remark'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_repair_attendance')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'creater_id')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_repair_attendance', 'column', 'creater_id'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '提交人ID',
   'user', @CurrentUser, 'table', 'bd_repair_attendance', 'column', 'creater_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_repair_attendance')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'create_time')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_repair_attendance', 'column', 'create_time'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '提交时间',
   'user', @CurrentUser, 'table', 'bd_repair_attendance', 'column', 'create_time'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_repair_attendance')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'is_del')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_repair_attendance', 'column', 'is_del'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '0：正常，-1:已删除',
   'user', @CurrentUser, 'table', 'bd_repair_attendance', 'column', 'is_del'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_repair_attendance')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'pc_ip')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_repair_attendance', 'column', 'pc_ip'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   'ip',
   'user', @CurrentUser, 'table', 'bd_repair_attendance', 'column', 'pc_ip'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_repair_attendance')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'pc_name')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_repair_attendance', 'column', 'pc_name'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '计算机名称',
   'user', @CurrentUser, 'table', 'bd_repair_attendance', 'column', 'pc_name'
go

/*==============================================================*/
/* Index: order_index_repair_attendance                         */
/*==============================================================*/




create unique nonclustered index order_index_repair_attendance on bd_repair_attendance (order_no ASC)
go
